﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LiJu
{
    public partial class UpdatePassword : Form
    {
        public UpdatePassword()
        {
            InitializeComponent();
        }

        //public DataTable UserData { get; set; }

        //public static string username { get; set; }

        //public static string userpassword { get; set; }

        //public static string id { get; set; }

        public static DataTable userdata { get; set; }

        private void Confirmbutton_Click(object sender, EventArgs e)
        {

            if (userdata.Rows.Count > 0)
            {
                if (!string.IsNullOrEmpty(NewPasswordTextBox.Text) && !string.IsNullOrEmpty(OldPasswordTextBox.Text))
                {
                    if (userdata.Rows[0][3].ToString() == OldPasswordTextBox.Text)
                    {
                        int result = BLL.Bll.UpdateUserManagerData(userdata.Rows[0][0].ToString(), userdata.Rows[0][1].ToString(), userdata.Rows[0][2].ToString(), NewPasswordTextBox.Text, userdata.Rows[0][4].ToString(), userdata.Rows[0][5].ToString());
                        if (result > 0)
                        {
                            MessageBox.Show("修改密码成功!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("旧密码不匹配!");
                    }
                }
                else
                {
                    MessageBox.Show("新密码不能为空");
                    OldPasswordTextBox.Text = "";
                    NewPasswordTextBox.Text = "";
                }
            }


        }
    }
}
